package cn.edu.zust.se.service.share.controller;

import cn.edu.zust.se.api.common.R;
import cn.edu.zust.se.api.entity.bo.ShareLinkBo;
import cn.edu.zust.se.service.share.service.ShareLinkService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ShareLink")
@RequiredArgsConstructor
public class ShareLinkController {
    private final ShareLinkService shareLinkService;

    /**
     * 创建分享链接
     * @param bo
     * @return
     */
    @PostMapping("")
    public R<Void> createShareLink(@RequestBody ShareLinkBo bo) {
        Boolean success = shareLinkService.createShareLink(bo);
        if (!success) {
            return R.fail();
        }
        return R.ok();
    }
    /**
     * 检查分享链接
     * @param bo
     * @return
     */
    @PostMapping("/check")
    public R<Void> checkShareLink(@RequestBody ShareLinkBo bo) {
        Boolean success = shareLinkService.checkShareLink(bo);
        if (!success) {
            return R.fail();
        }
        return R.ok();
    }


}
